{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <form id="myform" action="{:U('kefu/edit')}" method="post">
        <input type="hidden" id="id" name="id" value="{$vo['id']}" />

        <div class="form-group row">
            <label class="col-sm-2 form-control-label">客服名称</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" name="name" value="{$vo['name']}" validate="required:true,en_num:true, minlength:2, maxlength:20" />
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 form-control-label">客服类型</label>
            <div class="col-xs-4">
                <select class="form-control" name="type">
                    <option value="1" {eq name="vo.type" value="1"}selected{/eq}>QQ</option>
                    <option value="2" {eq name="vo.type" value="2"}selected{/eq}>旺旺</option>
                    <option value="3" {eq name="vo.type" value="3"}selected{/eq}>Skype</option>
                </select>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 form-control-label">ID或代码</label>
            <div class="col-xs-4">
                <textarea  id="code" name="code" class="form-control" rows="3" cols="40">{$vo['code']}</textarea>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 form-control-label">状态</label>
            <div class="col-xs-4">
                <input type="radio" name="status" value="1" {eq name="vo['status']" value="1"}checked="checked"{/eq} />启用
                <input type="radio" name="status" value="0" {eq name="vo['status']" value="0"}checked="checked"{/eq} />禁用
            </div>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary ajax_form_edit">提交</button>
            <button type="button" class="btn btn-danger" onclick="javascript:history.back(-1);return false;">返回</button>
        </div>
    </form>
</div>
{/block}

{block name="script"}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });
            } else {
                layer.msg(data.info, {
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        }
    </script>
{/block}